import React, { useEffect } from 'react'
import PubSub from 'pubsub-js'

import Son1 from './Son1'
export default function Father1() {
  useEffect(() => {
    // 订阅消息
    let fanfanId = PubSub.subscribe('fanfan', (msg, data) => {
      console.log('----- Father1 组件 -----')
      console.log('msg: ', msg)
      console.log('data: ', data)
      console.log('----- Father1 End -----')
    })

    return () => {
      // 取消订阅
      PubSub.unsubscribe(fanfanId)
    }
  }, [])
  return (
    <div>
      <Son1 />
    </div>
  )
}
